<style>
    .layui-form-item .layui-input-company {width: auto;padding-right: 10px;line-height: 38px;}
</style>
<div class="layuimini-container layuimini-page-anim">
    <div class="layuimini-main">

<form class="layui-form" action="" lay-filter="svrPv">
<div class="layuimini-main">
	<div class="layui-form layuimini-form">
		<div class="layui-form-item">
			<label class="layui-form-label required">公司名称</label>
			<div class="layui-input-block">
				<input type="text" name="name" lay-verify="required"
					lay-reqtext="不能为空,长度小于50个字" maxLength='50' placeholder="和工商登记名一致"
					value="" class="layui-input">
				<input type="hidden" name="id" /><!--  -->	
				<input type="hidden" name="type" /><!--  -->	
				<input type="hidden" name="status" /><!--  -->	
				<input type="hidden" name="createTime" /><!--  -->	
				<!-- <input type="hidden" name="modifyTime" /> -->	
				<!--  <tip>请填写服务商名称。需要服务商</tip> -->
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label required">公司简称</label>
			<div class="layui-input-block">
				<input type="text" name="nameShort"  disabled="disabled"
					value="" class="layui-input">
					<tip>公司简称,不能修改</tip>
			</div>
		</div>
		<div class="layui-form-item" id="area-picker">
			<div class="layui-form-label required">区域</div>
			<div class="layui-input-inline" style="width: 200px;">
				<select name="province" class="province-selector" disabled="disabled"
					lay-filter="province-1">
					<option value="">请选择省</option>
				</select>
			</div>
			<div class="layui-input-inline" style="width: 200px;">
				<select name="city" class="city-selector" disabled="disabled"
					lay-filter="city-1">
					<option value="">请选择市</option>
				</select>
			</div>
			<div class="layui-input-inline" style="width: 200px;">
				<select name="county" class="county-selector" 
					lay-filter="county-1">
					<option value="">请选择区</option>
				</select>
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label required">地址</label>
			<div class="layui-input-block">
				<input type="text" name="addar" maxLength='50'
					placeholder="长度小于50个字" value="" class="layui-input">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label required">电话</label>
			<div class="layui-input-block">
				<input type="number" name="tel" maxLength='20'
					placeholder="长度小于20个字" lay-verify="required" lay-reqtext="不能为空"
					value="" class="layui-input">
			</div>
		</div>
		<div class="layui-form-item">
			<div class="layui-input-block">
				<button class="layui-btn layui-btn-normal" lay-submit
					lay-filter="saveBtn">确认保存</button>
			</div>
		</div>
	</div>
</div>
</form>
    </div>
</div>
<script>
    layui.use(['form', 'table','layarea'], function () {
        var form = layui.form,
            layer = layui.layer,
            table = layui.table,
            layarea = layui.layarea,
            //data = layui.data,
            $ = layui.$;
            
            $.ajax({
				url: "/isp/getOwn",
				type: 'get',
				async: false,
				dataType: 'json',
				success: function(data) {
					window.svrInitData= data
					//console.log(data);
				}
			});
        /**
         * 初始化表单，要加上，不然刷新部分组件可能会不加载
         */
        //表单初始赋值,
        form.val("svrPv", window.svrInitData)
 		form.render();  
        
        //layer.alert(JSON.stringify(window.data));
        
		layarea.render({
		        elem: '#area-picker',
		        	data:window.svrInitData,
		        change: function (res) {
		            //选择结果
		            //console.log(res);
		        }
		    });
 		     
         //监听提交
        form.on('submit(saveBtn)', function (data) {
        	$.ajax({
				url: "/isp",
				type: 'post',
				async: false,
				data : JSON.stringify(data.field),//要转换为字符格式
				dataType: 'json',
				contentType:"application/json",
				success: function(data) {
					layer.alert('保存成功!!');
				},
				error: function(data) {
					layer.alert('保存失败!!');
				}
			});
            return false;
        });
    });
</script>